﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Domain.Ranges
{
    /// <summary>
    /// Specifications for the determiniation if an element is in a given range.
    /// </summary>
    [TestClass]
    public class WhenDeterminingIfElementIsIncludedInRange
    {
        /// <summary>
        /// Should return true if the date is in the period.
        /// </summary>
        [TestMethod]
        public void ShouldReturnTrueWhenElementIsInRange()
        {
            Range<DateTime> dateTimeRange = RangeFactory.GetRangeForDaysFromFirstJanuary2000(10);
            DateTime valueInRange = dateTimeRange.Begin.AddDays(1);

            Assert.IsTrue(dateTimeRange.Includes(valueInRange));
        }

        /// <summary>
        /// Should return ture if the date is the begin of the period.
        /// </summary>
        [TestMethod]
        public void ShouldReturnTrueWhenElementIsBeginOfRange()
        {
            Range<DateTime> dateTimeRange = RangeFactory.GetRangeForDaysFromFirstJanuary2000(10);
            DateTime valueInRange = dateTimeRange.Begin;

            Assert.IsTrue(dateTimeRange.Includes(valueInRange));
        }

        /// <summary>
        /// Should return true when the date is the end of the period.
        /// </summary>
        [TestMethod]
        public void ShouldReturnTrueWhenElementIsEndOfRange()
        {
            Range<DateTime> dateTimeRange = RangeFactory.GetRangeForDaysFromFirstJanuary2000(10);
            DateTime valueInRange = dateTimeRange.End;

            Assert.IsTrue(dateTimeRange.Includes(valueInRange));
        }

        /// <summary>
        /// Should return false when the date is before the period.
        /// </summary>
        [TestMethod]
        public void ShouldReturnFalseWhenElementIsBeforeBegin()
        {
            Range<DateTime> dateTimeRange = RangeFactory.GetRangeForDaysFromFirstJanuary2000(10);
            DateTime valueBeforeRange = dateTimeRange.Begin.AddDays(-1);

            Assert.IsFalse(dateTimeRange.Includes(valueBeforeRange));
        }

        /// <summary>
        /// Should return false when the date is after the period.
        /// </summary>
        [TestMethod]
        public void ShouldReturnFalseWhenElementIsAfterEnd()
        {
            Range<DateTime> dateTimeRange = RangeFactory.GetRangeForDaysFromFirstJanuary2000(10);
            DateTime valueAfterRange = dateTimeRange.End.AddDays(1);

            Assert.IsFalse(dateTimeRange.Includes(valueAfterRange));
        }
    }
}